<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html>
<html>
<head>
    <title>sunny-mvc</title>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <jsp:include page="../../common.jsp"></jsp:include>
    <jsp:include page="../../../common_easyui.jsp"></jsp:include>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.css">
    <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script>
<html>
<head>
    <title></title>
    <style>
        .switch {
            width: 60px;
        }
    </style>
    <script>
        function disableBtns() {
            $("input[type='button']").attr("disabled", true);
        }

        function enableBtns() {
            $("input[type='button']").attr("disabled", false);
        }
    </script>
</head>
<body>
<div data-role="page">
    <div data-role="header">
        <h1>去哪儿吃</h1>
    </div>

    <div data-role="collapsible" data-collapsed="false">
        <h1>提交</h1>
        <form method="post">
            <ul data-role="listview">
                <c:forEach var="r" items="${rests}">
                    <li>
                        <div data-role="fieldcontain">
                            <span style="font-size: 22px"><c:out value="${r.name}"/>&nbsp</span>
                            <select name="switch" id="switch" data-role="slider" class="switch">
                                <option value="on"></option>
                                <option value="off"></option>
                            </select>
                        </div>
                    </li>
                </c:forEach>
            </ul>
            <div style="margin: 0px auto">
                <input type="button" data-inline="true" id="submitRecord" value="提交">
                <input type="reset" data-inline="true" value="重置">
                <input type="button" data-inline="true" id="getResult" value="查看结果">
                <a href="javascript:disableBtns()">diable</a>
                <a href="javascript:enableBtns()">enable</a>
            </div>
            <script>
                $("#submitRecord").click(function(){
                    alert("submit");
                    $.post("<%=basePath%>eat/addRt.do",{
                                'projectId': projectId
                                ,'projectName': projectName
                                ,'typeStr' : projectType
                            },
                            function(data) {
                                alert(data);
                            },
                            "text");
                })

                $("#getResult").click(function(){
                    alert("getResult");
                })

            </script>
        </form>
    </div>

    <div data-role="collapsible" data-collapsed="true">
        <h1>添加地点</h1>
        <div data-role="fieldcontain">
            <label for="restaurantname">名称：</label>
            <input type="text" name="restaurantname" id="restaurantname">
        </div>
        <input type="submit" data-inline="true" id="addNewRest" value="提交">
    </div>
    <script>
        $("#addNewRest").click(function(){
            alert("addNewRest");
        })
    </script>
    <div data-role="footer">
        <h1>去哪儿吃</h1>
    </div>
</div>
</body>
</html>
